package com.aurora.demo.api;

import com.aurora.demo.api.param.QueryParam;
import com.aurora.demo.service.KeogramService;
import com.aurora.demo.service.MetaService;
import com.aurora.demo.util.KeogramUtil;
import com.aurora.demo.util.Result;
import com.aurora.demo.util.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.management.Query;
import java.awt.image.BufferedImage;
import java.util.List;

@Api(tags = "3.keogram相关接口")
@RestController
@RequestMapping("/keogram")
public class KeogramController {

    @Autowired
    private MetaService metaService;

    @Autowired
    private KeogramService keogramService;

    @ApiOperation("根据查询条件获取一张keogram")
    @GetMapping("/find")
    public Result<byte[]> getKeogram(QueryParam queryParam) {
        List<String> nameList = metaService.getNameBySelective(queryParam);
        byte[] keogram = keogramService.getKeogram(nameList);

        System.out.println(keogram);
        return ResultGenerator.genSuccessResult(keogram);
    }
}
